/*
 * TurdletContext.java
 *
 * Created on October 21, 2006, 2:53 AM
 *
 */

package tomkitty.turdlet;

import tomkitty.server.*;
import tomkitty.util.*;
import java.io.*;
import java.util.*;
import java.net.*;

/**
 *
 * @author micha
 */
public class TurdletContext {
	
	private BufferedReader in;
	private HttpPrintStream out;
	private HttpRequest request;
	private Hashtable<Object,Object> registeredData;
	private ConnectionHandler handler;
	
	public void setSocket(Socket sock) {
		try {
			in = new BufferedReader(new InputStreamReader(sock.getInputStream()));
			out = new HttpPrintStream(sock.getOutputStream()); 
		} catch (IOException e) {
			in = null;
			out = null;
		}
	}

	public void setIn(BufferedReader in) {
		this.in = in;
	}

	public BufferedReader getIn() {
		return in;
	}

	public void setOut(HttpPrintStream out) {
		this.out = out;
	}

	public HttpPrintStream getOut() {
		return out;
	}

	public void setRequest(HttpRequest req) {
		request = req;
	}

	public HttpRequest getRequest() {
		return request;
	}

	public void setRegisteredData(Hashtable<Object,Object> regData) {
		registeredData = regData;
	}

	public Hashtable<Object,Object> getRegisteredData() {
		return registeredData;
	}

	public void setHandler(ConnectionHandler hlr) {
		handler = hlr;
	}

	public ConnectionHandler getHandler() {
		return handler;
	}

	public TurdletContext(Socket sock, HttpRequest req, 
			Hashtable<Object,Object> regData, ConnectionHandler hlr) {
		setSocket(sock);
		request = req;
		registeredData = regData;
		handler = hlr;
	}

	public TurdletContext() {
	}
}
